/**
 * 
 */
package org.braketester.model;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.nio.DoubleBuffer;

import org.braketester.entry.ExceptionResolver;
import org.extdev.libraries.ltr.LTRException;
import org.extdev.protocol.ltr.LTR212LibProtocol;

/**
 * @author LAP
 *
 */
public class LTR212ClearVoltageProtocol extends LTR212LibProtocol {
	private VoltageOutputStream voltageOutputStream;
	
	public LTR212ClearVoltageProtocol() throws SecurityException, IOException {
		super();
		voltageOutputStream = new VoltageOutputStream();
	}
	
	@Override
	public InputStream getInputStream() {
		return voltageOutputStream;
	}
	
	private class VoltageOutputStream extends ObjectInputStream {
		public VoltageOutputStream() throws SecurityException, IOException {
			super();
		}
		
		@Override
		protected Object readObjectOverride() throws IOException,
				ClassNotFoundException {
			DoubleBuffer ret = null;
			try {
				ret = getData();
			} catch (LTRException e) {
				ExceptionResolver.getInstance().logException(e);
			}
			return ret;
		}
		
		
	}
}
